package drone.basis.util ;

import java.awt.Image ;
import java.awt.image.BufferedImage ;
import java.io.File ;
import java.io.FileInputStream ;

import javax.imageio.ImageIO ;

public class ImageUtil
{

	public static boolean isImage (
			File file
	)
	{
		try
		{
			Image image = ImageIO.read ( file ) ;
			return image != null ;
		} catch ( Exception e )
		{
			return false ;
		}
	}

	public static int getWidth (
			File file
	)
	{
		try
		{
			BufferedImage sourceImg = ImageIO.read ( new FileInputStream ( file ) ) ;
			return sourceImg.getWidth ( ) ;
		} catch ( Exception e )
		{
			return 0 ;
		}
	}

	public static int getHeight (
			File file
	)
	{
		try
		{
			BufferedImage sourceImg = ImageIO.read ( new FileInputStream ( file ) ) ;
			return sourceImg.getHeight ( ) ;
		} catch ( Exception e )
		{
			return 0 ;
		}
	}
}
